Two F = Mapvalues (F, C ("small", "medium", "large"), C ("s", "M", "L"))3. Remove any unused levels in the factor-droplevels ()The following R language code will eliminate the excess levels in factor F:Droplevels (f)variable Shape1. Variable substitution-match ()To replace some values with other specific values, you can use the match function. The following R language code replaces the "Ctr1", "Trt1", and "Trt2" values in the oldvals of the group column of the data frame PG with "No", "Yes", an
Nginx Log Example172.16.1.1 - - [04/Feb/2015:23:40:01 +0800] "POST /api/message/query HTTP/1.1" 200 52 "-" "Apache-HttpClient/4.2 (java 1.5)" "-" "message.test.com" "172.16.3.159" "-" "0.116" "-" "0.116" "-" remote_addr_ac_logon Remove the time, URL, request size, remove the sub(/\[/,"",$4) brackets in the period, and sub(/Feb/,"2",$4) replace the Fed with 2awksubfunction is used to replace the string, the statement is used alone, if the assignment statement is used, if a=sub(/Feb/,"2",$4) a=
occurred in 1960-2010, and we only focus on 1990-2010 data#只取1990年后的数据ufo.us #再画一次直方图#我们的目的是发现目击事件的周期性规律, aggregations should be aggregated over a period of time, such as monthly aggregation, so you need to count the number of UFO sightings per state each month#以下代码给ufo. US adds a new column that is Yearmonth, which extracts the year and month of the witness time, and Strftime is the string that is converted into a date typeUfo.us$yearmonth #使用ddply函
R language learning resources, r Language Learning
Getting started video tutorial
R language beginner course (1)-R language Quick Start http://cos.name/videos/intro-2-r/
Code
# Object 1 + 1 * 3c (1, 2, 3, 4, 5) c ('helloworld', 'I am a R user') c ("hehe", "haha") 1: 66: 1exp () log () a
Running result
> # Object> 1 + 1*3 [1] 4> c (1, 2, 3, 4, 5) [1] 1 2 3 4 5> c ('helloworld ', 'I am a R user') [1] "helloworld" "I am a R user"> c ("hehe", "haha ") [1] "hehe" "haha"> [1] 1 2 3 4 5 6> 6[ 1] 6
Do data preprocessing has been using hardly Wickham Plyr software package, the amount of data is slightly larger, the basic use of data.table software package. Hardly Wickham's Dplyr package has been out for some time, and has improved in performance. For later use, make some notes.These five functions provide the basis of a language of data manipulation. At the more basic level, you can only alter a tidy data frame in five useful ways:you can reorder the rows ( arrange() ), pick Observations an
by Ggplot (Uspopage, AES (x = year, y = Thousands, fill = agegroup)) + # area graph function Geom_area ()Operating effect:Obviously, each packet data has a size relationship. As a result, you can set the color palette to fade color. The R language implementation code looks like this:# base function Ggplot (Uspopage, AES (x = year, y = Thousands, fill = agegroup)) + # area graph function Geom_area () + # Palette ruler: Breaks invert legend Order Scale_fill_brewer (palette = "Blues", breaks
Getting Started video tutorialsBasic R Language Course (1)-Quick Start for R language http://cos.name/videos/intro-2-r/Code#对象1 +1*3c (1,2,3,4,5) C (' HelloWorld ', ' I am a R user ') C ("hehe", "haha") 1:66:1exp (1:4) log (1:3) aRun results> #对象 > 1+1*3[1] 4> C (1,2,3,4,5) [1] 1 2 3 4 5> C (' HelloWorld ', ' I am a R user ') [1] "HelloWorld" "I am a R use R "> C (" hehe "," haha ") [1]" hehe "" haha "> 1:6[1] 1 2 3 4 5 6> 6:1[1] 6 5 4 3 2 1> exp (1:4) [1] 2.718282 7.389056 20.085537 54.598150>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.